package com.qfedu.edu.iotserver.controller;


import com.qfedu.edu.iotserver.service.TenantService;
import com.qfedu.edu.pojo.Tenant;
import com.qfedu.edu.result.R;
import com.qfedu.edu.vo.TenantAuditVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 租户表 前端控制器
 * </p>
 *
 * @author xiaobobo
 * @since 2024-09-13
 */
@RestController
@RequestMapping("/iotserver/tenant")
@Api(description = "租户模块",tags = "租户模块")
public class TenantController {

    @Autowired
    private TenantService tenantService;

    /**
     * 租户的注册
     * @param tenant
     * @return
     */
    @PostMapping("/register")
    @ApiOperation("租户注册")
    @ApiImplicitParam(name = "token",value = "用户令牌",required = true,dataType = "string",paramType = "header")
    public R  register(@RequestBody Tenant tenant){
        tenantService.register(tenant);
        return R.ok();
    }


    /**
     * 租户审核的接口
     * @param tenantAuditVo
     * @return
     */
    @PostMapping("audit")
    @ApiOperation("租户审核接口")
    @Secured("ROLE_admin")
    @ApiImplicitParam(name = "token",value = "用户令牌",required = true,dataType = "string",paramType = "header")
    public R audit(TenantAuditVo tenantAuditVo){
        tenantService.audit(tenantAuditVo);
        return R.ok();
    }

}

